package com.lingnan.eduservice.mapper;

import com.lingnan.eduservice.entity.po.EduCoursePublishVO;
import com.lingnan.eduservice.entity.po.EduCoursePO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 *
 * @author zzd
 * @since 2021-08-17
 */
public interface EduCourseMapper extends BaseMapper<EduCoursePO> {

    /**
     * 根据课程ID查询课程最终确认信息
     * @param courseId
     * @return
     */
    @Select(" SELECT " +
            " course.`id`,course.`title`,course.`cover`,course.`lesson_num` AS  lessonNum ,course.`price`, " +
            " teacher.`name` as teacherName, " +
            " subject1.`title` AS subjectLevelTwo,subject2.`title` AS subjectLevelOne " +
            " FROM edu_course AS course " +
            " LEFT JOIN edu_teacher teacher ON teacher.`id` = course.`teacher_id` " +
            " LEFT JOIN edu_subject subject1 ON subject1.id = course.`subject_id` " +
            " LEFT JOIN edu_subject subject2 ON subject2.`id` = course.`subject_parent_id` " +
            " WHERE course.`id` = #{courseId} ")
    public EduCoursePublishVO findCoursePublishById(String courseId);

}
